using System;
using mojoPortal.Web;

namespace ud_SignIn
{
    public partial class SignInModule : SiteModuleControl
    {
        private SignInConfiguration config = new SignInConfiguration();
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            Load += Page_Load;
            EnableViewState = false;
        }

        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated && !Request.Url.ToString().Contains("Admin"))
            {
                Visible = false;
                return;
            }
            LoadSettings();
            PopulateLabels();
            PopulateControls();
        }

        private void PopulateControls()
        {

        }

        protected virtual void PopulateLabels()
        {

        }


        protected virtual void LoadSettings()
        {
            pnlContainer.ModuleId = ModuleId;
            config = new SignInConfiguration(Settings);
            if (!config.CustomCssClass.Equals(string.Empty)) { pnlContainer.CssClass += " " + config.CustomCssClass; }
            if (Request.IsSecureConnection) return;
            if (WebConfigSettings.ShowWarningWhenSslIsAvailableButNotUsedWithLoginModule)
            {
                bool sslIsAvailable = SiteUtils.SslIsAvailable();
                lblSslWarning.Visible = sslIsAvailable;
            }
        }
    }
}
